package com.youlu.campus.admin.auth.shiro.exception;

import com.youlu.campus.common.exception.ApiErrorCode;
import com.youlu.campus.base.exception.ErrorCode;
import org.apache.shiro.authc.AuthenticationException;

/**
 * Created by zhuhuaiqi on 2018/05/11.
 *
 * @author zhuhuaiqi
 */
public class AuthException extends AuthenticationException {

    protected ApiErrorCode errorCode;

    public AuthException(ApiErrorCode errorCode) {
        this.errorCode = errorCode;
    }

    public AuthException(ApiErrorCode errorCode, Throwable cause) {
        this.errorCode = errorCode;
    }

    public ApiErrorCode getErrorCode() {
        return this.errorCode;
    }

    public final static String formatMsg(ErrorCode errorCode) {
        return String.format("%s-%s", errorCode.getCode(), errorCode.getDescription());
    }
}
